package com.aaa.json.service;




import com.aaa.json.dao.DeptDao;
import com.aaa.json.dao.DeptDaoImpl;
import com.aaa.json.entity.Dept;

import java.util.List;
import java.util.Map;

/**
 * @program: javamvc-mvcup
 * @description:
 * @author: 诸葛龙辰
 * @create: 2023-03-03 21:21
 * @version:
 **/
public class DeptServiceImpl implements DeptService{
    private DeptDao deptDao = new DeptDaoImpl();
    @Override
    public List<Map> queryByPage1(int pageNo, int pageSize, Dept dept) {
        //计算开始值
        int start =(pageNo-1)*pageSize;
        //执行查询
        return deptDao.queryByPage1(start,pageSize,dept);
    }

    @Override
    public int queryTotal1(Dept dept) {
        return deptDao.queryTotal1(dept);
    }


    @Override
    public List<Map> queryAll1() {
        return deptDao.queryAll1();
    }

    @Override
    public Dept queryById1(int embId) {
         //根据编号查询集合
        List<Map> mapList = deptDao.queryById1(embId);
        //定义emp对象
        Dept dept = null;
        if(mapList!=null&&mapList.size()>0){
            Map map = mapList.get(0);
            //Integer empId, String empName, String sex, String phoneNum, String province, String hireDate, Integer deptNo, double salary, String password
            dept = new Dept(Integer.valueOf(map.get("emb_id").toString()),
                    map.get("emp_name")+"",Integer.valueOf(map.get("year")+""),
                    Integer.valueOf(map.get("month")+""),Double.valueOf(map.get("salary")+"" ),map.get("loc")+"");
        }
        return dept;
    }

   @Override
    public int add1(Dept dept) {
        return deptDao.add1(dept);
    }

    @Override
    public int update1(Dept dept) {
        return deptDao.update1(dept);
    }

    @Override
    public int deleteById1(int embId) {
        return deptDao.deleteById1(embId);
    }
}
